from numpy import square
from manimlib import *
#75cfb8
#bbdfc8
#f0e5d8
#ffc478
class p1(Scene):
    def construct(self):
        # self.add(NumberPlane())
        s=Square(side_length=5).set_fill('#ffc478',1)
        self.add(s)
        a,b,c,d=[-2.5,-2.5,0],[2.5,-2.5,0],[2.5,2.5,0],[-2.5,2.5,0]
        e,f=[0.5,-2.5,0],[-2.5,1.5,0]
        p1=Polygon(a,e,f).set_fill('#75cfb8',1)
        self.add(p1)
        for i in range(4):
            self.add(p1.copy().rotate_about_origin(0+i*PI/2),Line(e,f).rotate_about_origin(0+i*PI/2))
        for i in range(4):
            self.add(Line(e,f).rotate_about_origin(0+i*PI/2))

        b3=Brace(p1,DOWN)
        b4=Brace(p1,LEFT)
        b5=Brace(s,RIGHT)
        t3=Tex('30').next_to(b3,DOWN)
        t4=Tex('40').next_to(b4,LEFT)
        t5=Tex('50').next_to(b5,RIGHT)
        self.add(b3,b4,b5,t3,t4,t5)
        self.add(Tex('?'))
        self.wait()
class p2(Scene):
    def construct(self):
        # self.add(NumberPlane())
        s=Square(side_length=5)
        self.add(s)
        a,b,c,d=[-2.5,-2.5,0],[2.5,-2.5,0],[2.5,2.5,0],[-2.5,2.5,0]
        e,f=[0.5,-2.5,0],[-2.5,1.5,0]
        g,h=[2.5,0.5,0],[-1.5,-2.5,0]
        ef,gh=Line(e,f),Line(g,h)
        m=line_intersection(ef.get_start_and_end(),gh.get_start_and_end())
        #
        p1=Polygon(a,e,f).set_fill('#75cfb8',1)
        self.add(p1)
        for i in range(2):
            self.add(p1.copy().rotate_about_origin(0+i*PI/2),Line(e,f).rotate_about_origin(0+i*PI/2))
        for i in range(2):
            self.add(Line(e,f).rotate_about_origin(0+i*PI/2))

        b3=Brace(p1,DOWN)
        b4=Brace(p1,LEFT)
        b5=Brace(s,RIGHT)
        t3=Tex('30').next_to(b3,DOWN)
        t4=Tex('40').next_to(b4,LEFT)
        t5=Tex('50').next_to(b5,RIGHT)
        self.add(b3,b4,b5,t3,t4,t5)
        #
        self.add(Tex('A').next_to(s,DL),Tex('B').next_to(s,DR),Tex('C').next_to(s,UR),Tex('D').next_to(s,UL),Tex('E').next_to(e,UP),Tex('F').next_to(f,RIGHT),Tex('G').next_to(g,LEFT),Tex('H').next_to(h,UP),Tex('M').next_to(m,UP))
        self.wait()
